package com.xdog.web3.domain.transactionhistory;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;

@Data
@Schema(description = "特定交易详情响应数据")
public class TransactionDetailByTxHashResponse {
    
    @Schema(description = "链的唯一标识")
    private String chainIndex;
    
    @Schema(description = "交易发生的区块高度")
    private String height;
    
    @Schema(description = "交易时间；Unix时间戳的毫秒数格式")
    private String txTime;
    
    @Schema(description = "交易哈希")
    private String txhash;
    
    @Schema(description = "交易状态 1:pending 确认中 2:success：成功 3:fail：失败")
    private String txStatus;
    
    @Schema(description = "gas限额")
    private String gasLimit;
    
    @Schema(description = "gas消耗")
    private String gasUsed;
    
    @Schema(description = "gas价格")
    private String gasPrice;
    
    @Schema(description = "交易手续费")
    private String txFee;
    
    @Schema(description = "nonce")
    private String nonce;
    
    @Schema(description = "交易数量")
    private String amount;
    
    @Schema(description = "交易数量对应的币种简称")
    private String symbol;
    
    @Schema(description = "合约调用函数")
    private String methodId;
    
    @Schema(description = "L1执行的交易哈希")
    private String l1OriginHash;
    
    @Schema(description = "交易输入详情")
    private List<FromDetail> fromDetails;
    
    @Schema(description = "交易输出详情")
    private List<ToDetail> toDetails;
    
    @Schema(description = "内部交易详情")
    private List<InternalTransactionDetail> internalTransactionDetails;
    
    @Schema(description = "代币交易详情")
    private List<TokenTransferDetail> tokenTransferDetails;
    
    @Data
    @Schema(description = "交易输入详情")
    public static class FromDetail {
        
        @Schema(description = "发送/输入地址")
        private String address;
        
        @Schema(description = "位于当前交易输入的序号")
        private String vinIndex;
        
        @Schema(description = "位于上一笔输出里的序号")
        private String preVoutIndex;
        
        @Schema(description = "交易哈希，和 prevoutIndex 一起唯一确认输入的 UTXO")
        private String txHash;
        
        @Schema(description = "发送地址是否是合约地址 true:是 ；false：否")
        private Boolean isContract;
        
        @Schema(description = "交易数量")
        private String amount;
    }
    
    @Data
    @Schema(description = "交易输出详情")
    public static class ToDetail {
        
        @Schema(description = "接收/输出地址")
        private String address;
        
        @Schema(description = "输出的序号")
        private String voutIndex;
        
        @Schema(description = "接收地址是否是合约地址 true:是 ；false：否")
        private Boolean isContract;
        
        @Schema(description = "交易数量")
        private String amount;
    }
    
    @Data
    @Schema(description = "内部交易详情")
    public static class InternalTransactionDetail {
        
        @Schema(description = "交易发送方的地址")
        private String from;
        
        @Schema(description = "交易接受方的地址")
        private String to;
        
        @Schema(description = "from地址是否是合约地址")
        private Boolean isFromContract;
        
        @Schema(description = "to地址是否是合约地址")
        private Boolean isToContract;
        
        @Schema(description = "交易数量")
        private String amount;
        
        @Schema(description = "交易状态")
        private String state;
    }
    
    @Data
    @Schema(description = "代币交易详情")
    public static class TokenTransferDetail {
        
        @Schema(description = "交易发送方的地址")
        private String from;
        
        @Schema(description = "交易接受方的地址")
        private String to;
        
        @Schema(description = "from地址是否是合约地址")
        private Boolean isFromContract;
        
        @Schema(description = "to地址是否是合约地址")
        private Boolean isToContract;
        
        @Schema(description = "代币合约地址")
        private String tokenContractAddress;
        
        @Schema(description = "交易代币的简称")
        private String symbol;
        
        @Schema(description = "交易数量")
        private String amount;
    }
}